package deployment

import (
	"github.com/gin-gonic/gin"
	"go-kube-mgr/controllers"
	"go-kube-mgr/utils/kubeutils/kubeutils"
	"go-kube-mgr/utils/kubeutils/kubeutils/kubeutilsappsv1"
	"go-kube-mgr/utils/logs"
	appsv1 "k8s.io/api/apps/v1"
)

func Get(r *gin.Context) {
	logs.Debug(nil, "获取deployment详情")

	// 读取kubeconfig
	//  从前端读取 json 或form值， 这一部分可以抽象成函数
	var info *controllers.Info
	kubeconfig := controllers.NewInfo(r, info, "")

	// KubeUtilser接口是操作k8s资源的接口
	var kubeutilinterface kubeutils.KubeUtilser
	kubeutilinterface = kubeutilsappsv1.NewDeployment(kubeconfig, &appsv1.Deployment{})

	info.Get(r, kubeutilinterface)
	//下面这个方法在每一个资源的get方法中都会用到，所以把它抽象为函数
	/*
		item, err := kubeutilinterface.Get(info.Namespace, info.Name)
		if err != nil {
			msg := "查询失败：" + err.Error()
			info.ReturnData.Message = msg
			info.ReturnData.Status = 400
			logs.Error(nil, msg)
		} else {
			info.ReturnData.Data = make(map[string]interface{})
			info.ReturnData.Data["item"] = item
		}
		r.JSON(200, info.ReturnData)
	*/
}
